package com.spzx.channel.service.Impl;

import com.spzx.channel.service.IBrandService;
import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.domain.R;
import com.spzx.common.core.web.domain.AjaxResult;
import com.spzx.product.api.RemoteBrandService;
import com.spzx.product.api.domain.Brand;
import jakarta.servlet.ServletException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * projectName: spzx-parent
 *
 * @author: 王宝贵
 * time: 2024/10/9 11:42 周三
 * description:
 */
@Service
public class BrandServiceImpl implements IBrandService {

    @Autowired
    private RemoteBrandService remoteBrandService;


    /**
     * 查询所有的分类品牌
     * @return
     */
    @Override
    public List<Brand> selectBrandAll() throws ServletException {
        R<List<Brand>> brandAllList = remoteBrandService.getBrandAllList(SecurityConstants.INNER);
        if(brandAllList.getCode() ==R.FAIL){
            //发生异常
            throw  new ServletException("查询所有分类出现异常"+brandAllList.getMsg());
        }
        return brandAllList.getData();
    }
}